using System;
using System.Collections;
using System.Collections.Generic;

namespace Dojo {
    public class DojoCompressor {
        private FileSearcher searcher;
        private FileResolver resolver;
        private Copier copier;

        public DojoCompressor(FileSearcher searcher, FileResolver resolver, Copier copier) {
            this.searcher = searcher;
            this.resolver = resolver;
            this.copier = copier;
        }

        public void Compress(string destinationPath)
        {
            IList<ResolvedFile> files = searcher.Search();

            Hashtable resolvedFiles = new Hashtable();
            foreach (ResolvedFile file in files) {
                IList<ResolvedUrl> resolvedUrls = resolver.Resolve(file);
                foreach (ResolvedUrl url in resolvedUrls) {
                    try {
                        resolvedFiles.Add(url.Url, url);
                    } catch (Exception e) {
                        ;
                    }
                }
            }
            copier.CopyTo(destinationPath,resolvedFiles);
        }
    }
}